package com.ganbo.thread;

/**
 * @Author: ganbo
 * @Date: 2020/5/18 18:28
 */
public class InterruptDemo extends Thread {

    @Override
    public void run() {
        for (int i = 0; i < 50000; i++) {
            System.out.println("i=" + (i + 1));
        }
    }

    public static void main(String[] args) {
        try {
            InterruptDemo interruptDemo = new InterruptDemo();
            interruptDemo.start();

            Thread.sleep(3000);
            Thread.currentThread().interrupt();
            interruptDemo.interrupt();

            System.out.println(interruptDemo.isInterrupted());
            System.out.println("isAlive===>" + interruptDemo.isAlive());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


    }
}
